<template>
    <el-table 
      :cell-style="tablestyle"
      :header-cell-style="tablestyle"
      :data="tableData">
        <el-table-column label="执行人" prop="userName"></el-table-column>
        <el-table-column label="执行时间" prop="operatingTime"></el-table-column>
        <el-table-column label="执行结果" prop="remark"></el-table-column>
    </el-table>
</template>

<script>
import { getHistory } from '@/api/example'
import { formatTime } from '@/utils/validate'

export default {
  name: "historyTable",
  props:{
      exampleId:{
        type: String,
        require: true
      }
    },
  data () {
    return {
        tableData: [],
    };
  },
  methods:{
    //获取用例操作历史
    getHistoryData(){
      getHistory({'id':this.exampleId}).then((res) => {
        for (let i = 0; i < res.data.length; i++){
          res.data[i].operatingTime = formatTime(res.data[i].operatingTime)
        };
        this.tableData = res.data
      }).catch((err) => {
        this.$message({type: 'error',message: '出错了'})
        console.log(err)
      });
    },
    //表格文字居中返回方法
    tablestyle(){
      return "text-align:center;"
    },
  },
  mounted(){
    this.getHistoryData()
  },
}
</script>

<style lang="scss" scoped>

</style>